import React from 'react';
import { useNavigate } from 'react-router-dom';

import _Xq from '../MessageModule/Xq';

// Xq页面的包装组件，用于提供用户信息
export const XqWrapper: React.FC = () => {
  const savedUser = localStorage.getItem('currentUser');
  const selectedUser = localStorage.getItem('selectedUser');

  if (!savedUser) {
    // 如果没有用户信息，重定向到登录页面
    window.location.href = '/login';
    return null;
  }

  const userData = JSON.parse(savedUser);
  const selectedUserData = selectedUser ? JSON.parse(selectedUser) : null;

  return <_Xq currentUser={userData} selectedUser={selectedUserData} />;
};
